package demo.cxf.servlet;

import javax.servlet.ServletConfig;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;

import demo.cxf.service.HelloWorld;
import demo.cxf.service.HelloWorldImpl;

public class CXFDemoServlet extends CXFNonSpringServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void loadBus(ServletConfig sc) {
		super.loadBus(sc);
		Bus bus = getBus();
		BusFactory.setDefaultBus(bus);
		HelloWorldImpl helloworldImpl = new HelloWorldImpl();
		ServerFactoryBean svrFactory = new ServerFactoryBean();
		svrFactory.setServiceClass(HelloWorld.class);
		svrFactory.setAddress("/HelloWorld");
		svrFactory.setServiceBean(helloworldImpl);		
		svrFactory.create();
	}

}
